require"lfs"

dstDir = "c:/temp/"

function copyFunc(sourcePath, targetPath)
	local rf = io.open(sourcePath,"rb")
	local len = rf:seek("end")
	rf:seek("set",0)
	local data = rf:read(len)
	local wf = io.open(targetPath,"wb")
	wf:write(data,len)
	rf:close()
	wf:close()
end


function attrdir(path)
  for file in lfs.dir(path) do
    if file ~= "." and file ~= ".." then 		
		local f = path.. '/' ..file
		local attr = lfs.attributes (f)
		if attr.mode == "directory" then
			print(f .. "  -->  " .. attr.mode)
			attrdir(f)		
		else
			if string.find(file, '.mp3') then
				copyFunc(f, dstDir .. file)
			end
		end
    end
  end
end

attrdir("D:/zTemp/db")

--string = "Lua Tutorial"
--print(string.find(string,"Tutsorial"))
